package edu.gdit.health.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.gdit.health.base.result.PageTableRequest;
import edu.gdit.health.base.result.Results;
import edu.gdit.health.model.LoggingEvent;
import edu.gdit.health.service.LoggingEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import edu.gdit.health.dao.LoggingEventDao;
import sun.rmi.runtime.Log;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LoggingEventServicImpl implements LoggingEventService {

    @Autowired
    LoggingEventDao loggingEventDao;

    @Override
    public Results getLoggingEventSet(){
        return Results.success(1000,loggingEventDao.getAll());
    }

    @Override
    public Results getAll(PageTableRequest pageTableRequest) {
        PageHelper.startPage(pageTableRequest.getPage(),pageTableRequest.getLimit());
        List<LoggingEvent> loggingEventList=loggingEventDao.getAll();
        PageInfo pageInfo= new PageInfo(loggingEventList);
        return Results.success((int)pageInfo.getTotal(),loggingEventList);
    }
}
